refactor(annotation): use #src/* subpath imports for cross-directory refs - #245
Open
contextbotai[bot] wants to merge 1 commit into
Open
refactor(annotation): use #src/* subpath imports for cross-directory refs#245contextbotai[bot] wants to merge 1 commit into
contextbotai[bot] wants to merge 1 commit into
Conversation
…refs
Bring the @contextbridge/annotation package into compliance with the
repo's subpath-import convention (AGENTS.md > Imports): intra-package
cross-directory refs must use '#src/*' rather than relative '../' paths.
- Declare "imports": { "#src/*": "./src/*" } in package.json (was the
only backend/UI package with intra-package cross-dir imports missing it)
- Convert all 26 cross-directory '../' / '../../' imports to '#src/*'
- Same-directory './' sibling imports left relative, per the convention
No runtime behavior change — identical module targets.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
The repo's import convention (
AGENTS.md→ Imports) states:The
@contextbridge/annotationpackage violated this: it did not declare the#src/*mapping in itspackage.jsonand used relative..//../../paths for every cross-directory intra-package import. Every other backend/library package (cli,context,harness,instrumentation,server,shared,skills,storage,ui) already declares#src/*and complies. This was the single most egregious convention-violation class in the codebase — a clearly documented rule, the highest-frequency mechanical violation (26 import sites), and safely fixable with zero runtime behavior change.Changes
packages/annotation/package.json— added"imports": { "#src/*": "./src/*" }, matching every other package.#src/*across 11 files underpackages/annotation/src/:demo/DemoStage.tsx,element/ElementAdapter.ts,element/mermaid/MermaidBlock.tsx,element/mermaid/mermaidAdapter.ts,element/mermaid/mermaidAdapter.test.ts,element/useElementTargets.ts, and thetestHelpers/*files.import { App } from '../App.tsx';→import { App } from '#src/App.tsx';;'../../annotationTypes.ts'→'#src/annotationTypes.ts'../sibling imports were intentionally left relative, exactly as the convention permits.The changes are purely a module-resolution rename to identical targets — no logic, control flow, or exported surface changed.
Verification
bun run --cwd packages/annotation typecheck— passes (confirms#srcresolves undermoduleResolution: bundler, before and after).vite build(annotation) — succeeds, 4730 modules transformed; production single-file bundle produced andgrep -c xterm dist/index.htmlreturns0(the AGENTS.md invariant that demo-only xterm code never lands in the embedded CLI bundle still holds).bun run lint— passes (--max-warnings 0).bun run format:check— passes.Other violation classes noted (out of scope, for future runs)
.claude/rules/bun-native-apis.md): a fewreaddirSync-based directory walks in Bun-only code (packages/skills/src/skills.ts,packages/skills/scripts/check.ts,packages/storage/src/db/loadMigrations.macro.ts) could useBun.Glob. Judgment-heavy; deferred.??fallbacks vs destructured defaults: high raw count, but the vast majority are legitimate null-coalescing (map lookups, array indexing, regex matches), not options-bag defaults — low signal..astro/.mdxrelative imports: the website package intentionally does not declare#src/*and follows Astro's own asset/component import conventions; left untouched.